# -*- coding: UTF-8 -*-
# 使用中文注释之前要使用utf-8 编码
import math
import cmath
import random
import time
import calendar

print("hello, i am from file code")

a = 90;
if a > 100:
    print("true")
elif a > 80:
    print
    800000000;
else:
    print("false")

a = ["aa", "bb", "cc", "dd",
     "ee", ]
print
a;
total = """p1
p2
p3"""
print
total
# 是主食


print
"注释--";
a = 11;
t = 22;
print
a,;
print
t,;
a, b, c = 'aa', 'bb', 'cc'
print
a,;
print
b,;
print
c;

var1 = 1;
var2 = 2
print
var1,;
print
var2;

s = "123456"
print
s[1:7:2]
# list []
t = [1, 2, 3, 4, 5, 6];
t = t * 2;
print
t[0:6];
# tuple()
tuple = (1, 2, 3, 4, 5, 6);
print
tuple[0:6]
print
tuple[1];

# dictionary{}
dic = {};
aa = 'aa';
dic[aa] = ["aaaaa"];
print
dic[aa];
# 内置j函数
x = 12.02;
print
int(x);

print
x;
x = 65;
print
chr(x);
print
ord('A');
print
hex(100);
print
oct
# 运算符号
print
102 % 9
print
102 / 9
# 取整数
print
102 // 9
print
2 ** 10
print
10 / float(2.3);
a = 10;
b = 10;
print
a == b;
# 赋值
a = 100;
b = 9;
print
a == b;

# 逻辑运算符
# 逻辑运算符
# and  or not
x = "asd";
y = 20;
print
x and y;
print
x or y;
print
not x;
t = x and y;
print
t;
# in \ not in
s = "123";
print
'23w' in s;

a = 10;
b = 10;
print
a is b;
a = "1";
b = "1";
print
a is b;
print
a == b;
# if else elif 条件语句
if 22:
    print
    22
else:
    print
    "else"

a = 1;
while a < 10:
    if (a % 2 == 0):
        print
        a;
    else:
        print
        a
    a += 1;
a = 1;
if a == 1:
    print
    a;
elif a == 2:
    print
    a;
# while 循环

a = 100
while a > 0: a = a - 1;
print
a;
# for
for i in "python":
    print
    i;
tt = [1, 2, 3, 4, 5]
a = 0
for i in tt:
    a += i;
    print
    a;
fruits = ["Apple", "banana", "mango"];
a = "";
for i in fruits:
    a = a + "_" + i;
    print
    a
tupel = (1, 2, 3, 4);
for i in tuple:
    print
    i
x = 12
print
"----------------"
print
random.random()

var = "abcdef"
print
var[1];
print
var[2:4]
print
"\r"
print
"a" in var
for i in var:
    print
    i;
for i in range(len(var)):
    print
    i,;
    print
    var[i]
x = 12
print
"----------------"

# 格式化
print
"my name is %s" % ("dingqb")
print
"%c" % (65)
str1 = "my name is {}{}";
print
str1.format("abcd", "ef")
str1 = "{0} {0} {1}"
print
str1.format("abcd", "ef")
str1 = "{name}"
print
str1.format(name="123")
list = [123, 456, 789];
a = "{0[0]}{0[1]}{0[2]}".format(list)
a = int(a) - 1
print
a

dir = {"name": "dingqb", "age": 189}
print
"name=={name},age=={age}".format(**dir)


# reference
#
class AssignValue(object):
    def __init__(self, value):
        self.value = value


my_value = AssignValue(6)
print('value 为: {0.value}'.format(my_value))  # "0" 是可选的


class AssignValue2(object):
    def __init__(self, value):
        self.value = value


myvalue = AssignValue2(123)
print
"{.value}".format(myvalue)  ## "0" 是可选的 . 不可以缺少

a = "{:.4f}".format(math.pi);
a = float(a) + 1;
print
a;
print
"---";

for i in range(0, 5):
    for j in range(0, 5 - i):
        print
        "*",
    print
    "\n"
    print
    "\n"
# list 列表
list = ["aa", "bb", "cc"];
for i in list:
    print
    i;
list.append("dd");
for i in list:
    print
    i

for i in range(len(list)):
    print
    list[i]
print
"del\n\r\t"
for i in range(len(list)):
    if i == 3:
        del list[i]
for i in list:
    print
    i;
print
"\n\r\t 列表操作 +"
for i in list + list:
    print
    i
print
"\n\r\t 列表操作*"
for i in list * 3:
    print
    i
a = "长度=="
print
a,
print(len(list));
list2 = [11, 22, 33, 66, 55, 44];
tuple = (1, 2, 3);
print
max(list2);
print
min(list2)
print
list2.count(66);
print
list2.index(22);

list2.insert(0, 1);
list2.remove(1);
for i in list2:
    print
    i;
print
list2.pop();  # 弹出最后一个数据，并把结果返回
list2.reverse()
for i in list2:
    print
    i
list2.sort();
for i in list2:
    print
    i

# tuple 元组（a,v,b,）
print
"元组\r\t\n"
tup = (11, 22, 33,);
tup = tup * 2;
for i in tup:
    print
    i
print
len(tup)

for i in range(len(tup)):
    print
    tup[i]

print
tup

print
min(tup)
print
max(tup)
# dictionary 字典{a:az,b:bz}
print
"\r\t\n 字典"
dict = {"akey": "aava"}
print
dict["akey"]

dict["bkey"] = "bbva";
print
len(dict);

print
len(dict)

print
type(dict)

print
len(dict)

for i in dict.keys():
    print
    i
for i in dict.values():
    print
    i
# 时间
print
time.time()
tt = time.localtime(time.time());
print
tt;
print
tt.tm_year;
print
tt.tm_mon
print
tt.tm_mday

localtime = time.asctime(time.localtime(time.time()))
print
localtime
a = 10
while True:
    print
    time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    a = a + 1;
    if a > 10000:
        break
cal = calendar.month(2019, 9);
print
cal

print
time.altzone
for i in range(1, 10):
    print
    i
    print
    time.time();
#   time.sleep(1);


print(True == True)

sum = lambda a, b: a + b;
print("sum=="+str(sum(11, 22)))

print(calendar.leapdays(1990, 2000))
print("end")
